package mortal.game.control
{
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import flash.events.*;
    import modules.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guild.*;
    import mortal.game.view.guild.myGuild.*;
    import mortal.game.view.uiIconBtn.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildController extends Controller
    {
        private var _guildModule:GuildModule;
        private var _guildListModule:GuildListModule;
        private var _createWindow:CreateGuildWindow;
        private var _detailWindow:GuildDetailWindow;
        private var _contriWindow:GuildContibuteWindow;
        private var _inviteListWindow:InviteListWindow;
        private var _nominateWindow:NominateWindow;
        private var _taskGuideWindow:GuildTaskWindow;
        private var _applyListWindow:GuildApplyListWindow;
        private var _massSendWindow:GuildMassSendWindow;
        private var _welcomeNewWindow:GuildWelcomeNewMemberWindow;
        private var _welcomeListWindow:GuildWelcomeListWindow;
        private var _welcomeIcon:WelcomeHintIcon;
        private var _isAfterCreateSuccess:Boolean = false;
        private var _isSearch:Boolean = false;
        public static var curShowType:String = "";
        public static var isConditionSearch:Boolean;

        public function GuildController()
        {
            Dispatcher.addEventListener(GuildEventName.OpenCreateGuildWindow, this.onOpenCreateGuildWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenSeeGuildWindow, this.onOpenSeeGuildWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenGuildInviteListWindow, this.onOpenGuildInviteListWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenGuildNominateWindow, this.onOpenGuildNominateWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenGuildTaskGuideWindow, this.onOpenGuildTaskGuideWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenGuildContriWindow, this.onOpenGuildContriWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenGuildApplyListWindow, this.onOpenGuildApplyListWindowHandler);
            Dispatcher.addEventListener(GuildEventName.SortMember, this.onSortMemberHandler);
            Dispatcher.addEventListener(GuildEventName.OpenMassSendWindow, this.onOpenMassSendWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenWelcomeNewMemberWindow, this.onOpenWelcomeNewMemberWindowHandler);
            Dispatcher.addEventListener(GuildEventName.OpenWelcomeListWindow, this.onOpenWelcomeListWindowHandler);
            Dispatcher.addEventListener(EventName.OpenGuildWindow, this.onOpenGuildWindowHandler);
            Dispatcher.addEventListener(EventName.CloseGuildWindow, this.onCloseGuildWindowHandler);
            Dispatcher.addEventListener(EventName.GuildCreate, this.onGuildCreateHandler);
            Dispatcher.addEventListener(EventName.GuildCreateSuccess, this.onGuildCreateSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildGetInfo, this.onGuildGetHandler);
            Dispatcher.addEventListener(EventName.GuildGetInfoSuccess, this.onGuildGetInfoSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildGetMyInfoSuccess, this.onGuildGetMyInfoSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildSearch, this.onGuildSearchHandler);
            Dispatcher.addEventListener(EventName.GuildSearchSuccess, this.onGuildSearchSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildApply, this.onGuildApplyHandler);
            Dispatcher.addEventListener(EventName.GuildApplySuccess, this.onGuildApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildCancelApply, this.onGuildCancelApplyHandler);
            Dispatcher.addEventListener(EventName.GuildCancelApplySuccess, this.onGuildCancelApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildDealApply, this.onGuildDealApplyHandler);
            Dispatcher.addEventListener(EventName.GuildDealApplySuccess, this.onGuildDealApplySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildGetApplyList, this.onGuildGetApplyListHandler);
            Dispatcher.addEventListener(EventName.GuildGetApplyListSuccess, this.onGuildGetApplyListSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildGetPlayerList, this.onGuildGetPlayerListHandler);
            Dispatcher.addEventListener(EventName.GuildGetPlayerListSuccess, this.onGuildGetPlayerListSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildInvite, this.onGuildInviteHandler);
            Dispatcher.addEventListener(EventName.GuildInviteSuccess, this.onGuildInviteSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildDealInvite, this.onGuildDealInviteHandler);
            Dispatcher.addEventListener(EventName.GuildDealInviteSuccess, this.onGuildDealInviteSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildMemberOper, this.onGuildGuildMemberOperHandler);
            Dispatcher.addEventListener(EventName.GuildMemberOperSuccess, this.onGuildMemberOperSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildChangePurpose, this.onGuildChangePurposeHandler);
            Dispatcher.addEventListener(EventName.GuildChangePurposeSuccess, this.onGuildChangePurposeSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildChangeYYQQ, this.onGuildChangeYYQQHandler);
            Dispatcher.addEventListener(EventName.GuildChangeYYQQSuccess, this.onGuildChangeYYQQSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildNominate, this.onGuildNominateHandler);
            Dispatcher.addEventListener(EventName.GuildNominateSuccess, this.onGuildNominateSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildKickOut, this.onGuildKickOutHandler);
            Dispatcher.addEventListener(EventName.GuildKickOutSuccess, this.onGuildKickOutSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildQuit, this.onGuildQuitHandler);
            Dispatcher.addEventListener(EventName.GuildQuitSuccess, this.onGuildQuitSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildDisband, this.onGuildDisbandHandler);
            Dispatcher.addEventListener(EventName.GuildDisbandSuccess, this.onGuildDisbandSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildApplyPlayersGuild, this.onGuildApplyPlayersGuildHandler);
            Dispatcher.addEventListener(EventName.GuildApplyPlayersGuildSuccess, this.onGuildApplyPlayersGuildSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildUpdate, this.onGuildUpdateHandler);
            Dispatcher.addEventListener(EventName.GuildUpdateSuccess, this.onGuildUpdateSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildDonateMoney, this.onGuildDonateMoneyHandler);
            Dispatcher.addEventListener(EventName.GuildDonateMoneySuccess, this.onGuildDonateMoneySuccessHandler);
            Dispatcher.addEventListener(EventName.GuildSendMail, this.onGuildSendMailHandler);
            Dispatcher.addEventListener(EventName.GuildSendMailSuccess, this.onGuildSendMailSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildSendChat, this.onGuildSendChatHandler);
            Dispatcher.addEventListener(EventName.GuildSendChatSuccess, this.onGuildSendChatSuccessHandler);
            Dispatcher.addEventListener(EventName.GuildSendWelcome, this.onGuildSendWelcomeHandler);
            Dispatcher.addEventListener(EventName.GuildSendWelcomeSuccess, this.onGuildSendWelcomeSuccessHandler);
            
        }

        override public function get view() : IView
        {
            return this.initView();
        }

        override protected function initView() : IView
        {
            if (cache.guild.myGuildInfo)
            {
                curShowType = GuildShowType.MyGuildList;
                if (this._guildModule == null)
                {
                    this._guildModule = new GuildModule();
                    this._guildModule.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
                }
                GameController.guildManor.init();
                return this._guildModule;
            }
            else
            {
                curShowType = GuildShowType.NormalGuildList;
                if (this._guildListModule == null)
                {
                    this._guildListModule = new GuildListModule();
                    this._guildListModule.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStageHandler);
                }
                return this._guildListModule;
            }
        }

        private function onAddedToStageHandler(event:Event) : void
        {
            if (curShowType == GuildShowType.NormalGuildList)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildSearch, {camp:0, guildName:""}));
            }
            else
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetInfo, 0));
                this._guildModule.updatePlayerGuildInfoPanel(cache.guild.myGuildInfo);
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.GuildModuleShow));
            }
            
        }

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.GuildUpdateInfo, this.onGuildUpdateInfoHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildPushInviteInfo, this.onGuildPushInviteInfoHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildNewApply, this.onGuildNewApplyHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildWelcome, this.onGuildWelcomeHandler);
            NetDispatcher.addCmdListener(ServerCommand.GuildNewMember, this.onGuildNewMemberHandler);
            
        }

        private function onOpenGuildWindowHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            if (this._guildModule == null)
            {
                this._guildModule = this.view as GuildModule;
            }
            GameController.guildManor.init();
            this._guildModule.show();
            this._guildModule.showTabByIndex(_loc_2);
            
        }

        private function onCloseGuildWindowHandler(event:DataEvent) : void
        {
            if (this._guildModule && this._guildModule.isHide == false)
            {
                this._guildModule.hide();
            }
            
        }

        private function onOpenCreateGuildWindowHandler(event:DataEvent) : void
        {
            if (cache.role.entityInfo.level < GameConst.GuildCreatePlayerLevel)
            {
                MsgManager.addBroadCast("您的等级不足" + GameConst.GuildCreatePlayerLevel + "级，不能创建仙盟");
                
            }
            if (this._createWindow == null)
            {
                this._createWindow = new CreateGuildWindow();
            }
            this._createWindow.show();
            
        }

        private function onOpenSeeGuildWindowHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SMiniGuildInfo;
            if (this._detailWindow == null)
            {
                this._detailWindow = new GuildDetailWindow();
            }
            this._detailWindow.clear();
            this._detailWindow.show();
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetInfo, _loc_2.guildId));
            
        }

        private function onOpenGuildInviteListWindowHandler(event:DataEvent) : void
        {
            if (this._inviteListWindow == null)
            {
                this._inviteListWindow = new InviteListWindow();
            }
            this._inviteListWindow.updateListDataProvider(cache.guild.inviteList);
            this._inviteListWindow.show();
            
        }

        private function onOpenGuildNominateWindowHandler(event:DataEvent) : void
        {
            var _loc_2:* = cache.guild.curSelGuildPlayer;
            if (this._nominateWindow == null)
            {
                this._nominateWindow = new NominateWindow();
            }
            if (_loc_2)
            {
                this._nominateWindow.updateTip(_loc_2.miniPlayer.name);
            }
            this._nominateWindow.updatePosition(cache.guild.getPositionData());
            this._nominateWindow.show();
            
        }

        private function onOpenGuildTaskGuideWindowHandler(event:DataEvent) : void
        {
            if (this._taskGuideWindow == null)
            {
                this._taskGuideWindow = new GuildTaskWindow();
            }
            this._taskGuideWindow.updateTaskNum();
            this._taskGuideWindow.show();
            
        }

        private function onOpenGuildContriWindowHandler(event:DataEvent) : void
        {
            if (this._contriWindow == null)
            {
                this._contriWindow = new GuildContibuteWindow();
            }
            this._contriWindow.updateMaxAmount(cache.guild.getBrocadeBoxAmount());
            this._contriWindow.show();
            
        }

        private function onOpenGuildApplyListWindowHandler(event:DataEvent) : void
        {
            if (this._applyListWindow == null)
            {
                this._applyListWindow = new GuildApplyListWindow();
            }
            this._applyListWindow.show();
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetApplyList, cache.guild.myGuildInfo.guildId));
            
        }

        private function onOpenMassSendWindowHandler(event:DataEvent) : void
        {
            if (this._massSendWindow == null)
            {
                this._massSendWindow = new GuildMassSendWindow();
            }
            this._massSendWindow.show();
            
        }

        private function onOpenWelcomeNewMemberWindowHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SPublicMiniPlayer;
            if (this._welcomeNewWindow == null)
            {
                this._welcomeNewWindow = new GuildWelcomeNewMemberWindow();
            }
            this._welcomeNewWindow.updateWelcome(_loc_2);
            this._welcomeNewWindow.show();
            
        }

        private function onOpenWelcomeListWindowHandler(event:DataEvent) : void
        {
            if (this._welcomeListWindow == null)
            {
                this._welcomeListWindow = new GuildWelcomeListWindow();
            }
            this._welcomeListWindow.updateDataProvider(cache.guild.welcomeArray);
            this._welcomeListWindow.show();
            
        }

        private function onGuildCreateHandler(event:DataEvent) : void
        {
            var _loc_5:Boolean = false;
            var _loc_6:String = null;
            var _loc_2:* = event.data["option"] as EOperOption;
            var _loc_3:* = event.data["name"] as String;
            var _loc_4:* = event.data["purpose"] as String;
            if (StringHelper.getCharLength(StringHelper.trim(_loc_3)) == 0)
            {
                MsgManager.addBroadCast("仙盟名不能为空!");
                
            }
            if (_loc_2 == EOperOption.EOperOptionMoney)
            {
                _loc_5 = false;
                _loc_6 = GameDefConfig.instance.getEPrictUnitName(GameConst.GuildCreateNeedUnit);
                switch(GameConst.GuildCreateNeedUnit)
                {
                    case EPrictUnit._EPriceUnitCoin:
                    {
                        if (cache.role.money.coin >= GameConst.GuildCreateNeedMoney)
                        {
                            _loc_5 = true;
                        }
                        break;
                    }
                    case EPrictUnit._EPriceUnitCoinBind:
                    {
                        if (cache.role.money.coinBind + cache.role.money.coin >= GameConst.GuildCreateNeedMoney)
                        {
                            _loc_5 = true;
                        }
                        break;
                    }
                    case EPrictUnit._EPriceUnitGold:
                    {
                        if (cache.role.money.gold >= GameConst.GuildCreateNeedMoney)
                        {
                            _loc_5 = true;
                        }
                        break;
                    }
                    case EPrictUnit._EPriceUnitGoldBind:
                    {
                        if (cache.role.money.goldBind >= GameConst.GuildCreateNeedMoney)
                        {
                            _loc_5 = true;
                        }
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
                if (_loc_5 == false)
                {
                    MsgManager.addBroadCast("您身上的" + _loc_6 + "不足，不能创建仙盟!");
                    
                }
            }
            GameProxy.guildProxy.createGuild(cache.role.playerInfo.playerId, _loc_2, _loc_3, _loc_4);
            
        }

        private function onGuildCreateSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("恭喜你！创建仙盟成功！");
            if (this._createWindow)
            {
                this._createWindow.hide();
            }
            if (this._guildListModule)
            {
                this._guildListModule.hide();
            }
            this._isAfterCreateSuccess = true;
            
        }

        private function onGuildGetHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            GameProxy.guildProxy.getGuildInfo(_loc_2);
            
        }

        private function onGuildGetInfoSuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SGuildInfo;
            if (this._detailWindow == null)
            {
                this._detailWindow = new GuildDetailWindow();
            }
            this._detailWindow.clear();
            this._detailWindow.updateGuildInfo(_loc_2);
            this._detailWindow.show();
            
        }

        private function onGuildGetMyInfoSuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as SGuildInfo;
            cache.guild.guildInfo = _loc_2;
            if (this._guildModule)
            {
                this._guildModule.updateGuildInfoPanel(_loc_2);
            }
            
        }

        private function onGuildSearchHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["camp"] as int;
            var _loc_3:* = event.data["guildName"] as String;
            var _loc_4:* = event.data["startIndex"] as int;
            var _loc_5:* = event.data["isFull"] as Boolean;
            if (_loc_2 != 0 || _loc_3 != "")
            {
                isConditionSearch = true;
            }
            else
            {
                isConditionSearch = false;
            }
            GameProxy.guildProxy.searchGuilds(_loc_2, _loc_3, _loc_4, _loc_5);
            this._isSearch = true;
            
        }

        private function onGuildSearchSuccessHandler(event:DataEvent) : void
        {
            var _loc_7:int = 0;
            if (!this._isSearch)
            {
                
            }
            this._isSearch = false;
            var _loc_2:* = event.data["guilds"] as Array;
            var _loc_3:* = event.data["totalNum"] as int;
            var _loc_4:* = event.data["startIdx"] as int;
            var _loc_5:* = event.data["myRank"] as int;
            if (event.data["myRank"] as int != 0)
            {
                cache.guild.setMyGuildRank(_loc_5);
            }
            if (isConditionSearch)
            {
                cache.guild.guildArray = _loc_2;
            }
            else
            {
                _loc_7 = _loc_4 != 0 ? ((_loc_4 - 1)) : (0);
                cache.guild.pushToGuildArrayAtIndex(_loc_7, _loc_2);
            }
            var _loc_6:* = cache.guild.guildArray;
            if (curShowType == GuildShowType.NormalGuildList)
            {
                this._guildListModule.updateGuildDataProvider(_loc_2, _loc_3);
            }
            else
            {
                this._guildModule.updateGuildDataProvider(_loc_6, _loc_3);
            }
            if (_loc_2.length == 0)
            {
                MsgManager.addBroadCast("没有搜索到符合条件的仙盟！");
            }
            
        }

        private function onGuildUpdateInfoHandler(param1:SPlayerGuildInfo) : void
        {
            if (this._isAfterCreateSuccess)
            {
                this.initView().show();
                this._isAfterCreateSuccess = false;
            }
            else if (param1.guildId == 0)
            {
                if (this._guildModule && this._guildModule.isHide == false)
                {
                    this._guildModule.hide();
                }
            }
            else if (this._guildListModule && this._guildListModule.isHide == false)
            {
                this._guildListModule.hide();
            }
            if (this._guildModule)
            {
                this._guildModule.updatePlayerGuildInfoPanel(cache.guild.myGuildInfo);
            }
            
        }

        private function onGuildApplyHandler(event:DataEvent) : void
        {
            var _loc_2:* = cache.role.playerInfo.playerId;
            var _loc_3:* = event.data["guildId"] as int;
            if (cache.role.entityInfo.level < GameConst.GuildJoinPlayerLevel)
            {
                MsgManager.addBroadCast("您等级不足" + GameConst.GuildJoinPlayerLevel + "级，不能加入仙盟");
                
            }
            GameProxy.guildProxy.applyGuild(_loc_2, _loc_3);
            
        }

        private function onGuildApplySuccessHandler(event:DataEvent) : void
        {
            var _loc_3:GTileList = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:SMiniGuildInfo = null;
            var _loc_7:int = 0;
            var _loc_2:* = event.data as int;
            MsgManager.addBroadCast("你已成功发送仙盟申请信息");
            if (GuildController.curShowType == GuildShowType.NormalGuildList)
            {
                if (this._guildListModule && this._guildListModule.isHide == false)
                {
                    _loc_3 = this._guildListModule.guildListPanel.tileList;
                    _loc_4 = _loc_3.dataProvider.toArray();
                    _loc_7 = 0;
                    while (_loc_7 < _loc_4.length)
                    {
                        
                        _loc_6 = _loc_4[_loc_7] as SMiniGuildInfo;
                        if (_loc_2 == _loc_6.guildId)
                        {
                            _loc_5 = _loc_7;
                            break;
                        }
                        _loc_7++;
                    }
                    _loc_6.apply = true;
                    _loc_3.dataProvider.replaceItemAt(_loc_6, _loc_5);
                    _loc_3.invalidateItemAt(_loc_5);
                }
            }
            
        }

        private function onGuildCancelApplyHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["guildId"] as int;
            GameProxy.guildProxy.cancelApply(_loc_2);
            
        }

        private function onGuildCancelApplySuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["guildId"] as int;
            MsgManager.addBroadCast("取消入会申请成功");
            
        }

        private function onGuildDealApplyHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = event.data["toPlayerId"] as int;
            var _loc_4:* = event.data["oper"] as Boolean;
            GameProxy.guildProxy.dealApply(_loc_2, _loc_3, _loc_4);
            
        }

        private function onGuildDealApplySuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Boolean;
            if (_loc_2)
            {
                MsgManager.addBroadCast("您已同意了申请");
            }
            else
            {
                MsgManager.addBroadCast("您已拒绝了申请");
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetApplyList, cache.guild.myGuildInfo.guildId));
            
        }

        private function onGuildGetApplyListHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            GameProxy.guildProxy.getApplyList(_loc_2);
            
        }

        private function onGuildGetApplyListSuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as Array;
            this._applyListWindow.updateListData(_loc_2);
            
        }

        private function onGuildGetPlayerListHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            GameProxy.guildProxy.getGuildPlayerList(_loc_2);
            
        }

        private function onGuildGetPlayerListSuccessHandler(event:DataEvent) : void
        {
            var _loc_3:String = null;
            var _loc_4:Boolean = false;
            var _loc_2:* = event.data as Array;
            if (this._guildModule)
            {
                this._guildModule.updateMemListPanelProvider(_loc_2);
                _loc_3 = cache.guild.memSortType;
                _loc_4 = cache.guild.isOnlyOnline;
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.SortMember, {sortType:_loc_3, isOnlyOnline:_loc_4}));
            }
            
        }

        private function onSortMemberHandler(event:DataEvent) : void
        {
            var _loc_2:String = null;
            var _loc_3:Boolean = false;
            var _loc_4:Array = null;
            if (this._guildModule && this._guildModule.isHide == false)
            {
                _loc_2 = event.data["sortType"] as String;
                _loc_3 = event.data["isOnlyOnline"] as Boolean;
                _loc_4 = cache.guild.getSortedMemberArray(_loc_2, _loc_3);
                this._guildModule.updateMemListPanelProvider(_loc_4);
                cache.guild.memSortType = _loc_2;
                cache.guild.isOnlyOnline = _loc_3;
            }
            
        }

        private function onGuildInviteHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = event.data["toPlayerId"] as int;
            GameProxy.guildProxy.invitePlayer(_loc_2, _loc_3);
            
        }

        private function onGuildInviteSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("您已发出了邀请");
            
        }

        private function onGuildDealInviteHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = event.data["guildId"] as int;
            var _loc_4:* = event.data["oper"] as Boolean;
            GameProxy.guildProxy.dealInvite(_loc_2, _loc_3, _loc_4);
            
        }

        private function onGuildDealInviteSuccessHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["guildId"] as int;
            var _loc_3:* = event.data["oper"] as Boolean;
            if (_loc_3)
            {
                if (this._guildListModule)
                {
                    this._guildListModule.hide();
                }
                if (this._inviteListWindow)
                {
                    this._inviteListWindow.hide();
                }
                cache.guild.inviteList = [];
                this.view.show();
                MsgManager.addBroadCast("您已同意了邀请");
            }
            else
            {
                cache.guild.delInviteByGuildId(_loc_2);
                this._inviteListWindow.updateListDataProvider(cache.guild.inviteList);
                delete InviteGuildRender.dealDict[_loc_2];
                MsgManager.addBroadCast("您已拒绝了邀请");
            }
            
        }

        private function onGuildGuildMemberOperHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = event.data["toPlayerId"] as int;
            var _loc_4:* = event.data["toPosition"] as EGuildPosition;
            GameProxy.guildProxy.memberOper(_loc_2, _loc_3, _loc_4);
            
        }

        private function onGuildMemberOperSuccessHandler(event:DataEvent) : void
        {
            
        }

        private function onGuildChangePurposeHandler(event:DataEvent) : void
        {
            var _loc_2:int = 0;
            var _loc_3:* = event.data as String;
            GameProxy.guildProxy.changeGuildPurpose(_loc_2, _loc_3);
            
        }

        private function onGuildChangePurposeSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("您已成功修改了仙盟宗旨");
            
        }

        private function onGuildChangeYYQQHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["option"] as EOperOption;
            var _loc_3:* = event.data["number"] as String;
            GameProxy.guildProxy.changeYYQQ(_loc_2, _loc_3);
            
        }

        private function onGuildChangeYYQQSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("您已成功修改了仙盟交流信息");
            
        }

        private function onGuildKickOutHandler(event:DataEvent) : void
        {
            var guildPlayer:SGuildPlayer;
            var name:String;
            var htmlContent:String;
            var dataEvent:* = event;
            guildPlayer = dataEvent.data as SGuildPlayer;
            var myGuildInfo:* = cache.guild.myGuildInfo;
            if (guildPlayer && myGuildInfo)
            {
                if (myGuildInfo.position > guildPlayer.position)
                {
                    var onClickHandler:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.guildProxy.memberOper(0, guildPlayer.miniPlayer.entityId.id, EGuildPosition.EGuildNotMember);
                    Alert.resetToDefault();
                }
                
            }
            ;
                    name = HTMLUtil.addColor(guildPlayer.miniPlayer.name, "#ff5b5b");
                    htmlContent = "您确定将" + name + "踢出仙盟吗？";
                    Alert.show(htmlContent, null, Alert.OK | Alert.CANCEL, null, onClickHandler);
                }
                else
                {
                    MsgManager.addBroadCast("您没有权限把该玩家踢出仙盟");
                }
            }
            
        }

        private function onGuildKickOutSuccessHandler(event:DataEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetPlayerList, cache.guild.myGuildInfo.guildId));
            MsgManager.addBroadCast("成员已成功踢出仙盟");
            
        }

        private function onGuildNominateHandler(event:DataEvent) : void
        {
            var guildPlayer:SGuildPlayer;
            var toPosition:int;
            var htmlContent:String;
            var dataEvent:* = event;
            guildPlayer = dataEvent.data["toGuildPlayer"] as SGuildPlayer;
            toPosition = dataEvent.data["toPosition"] as int;
            var toPositionName:* = GameDefConfig.instance.getPositionName(toPosition);
            var myGuildInfo:* = cache.guild.myGuildInfo;
            if (guildPlayer && myGuildInfo)
            {
                if (myGuildInfo.position >= guildPlayer.position)
                {
                    var onClickHandler:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.guildProxy.memberOper(0, guildPlayer.miniPlayer.entityId.id, new EGuildPosition(toPosition));
                    Alert.resetToDefault();
                }
                
            }
            ;
                    if (guildPlayer.position == toPosition)
                    {
                        MsgManager.addBroadCast("该成员已是" + toPositionName);
                        
                    }
                    htmlContent = "您确定将" + guildPlayer.miniPlayer.name + "任命为仙盟的" + toPositionName + "吗？";
                    Alert.show(htmlContent, null, Alert.OK | Alert.CANCEL, null, onClickHandler);
                }
                else
                {
                    MsgManager.addBroadCast("您没有权限任命该成员");
                }
            }
            
        }

        private function onGuildNominateSuccessHandler(event:DataEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetPlayerList, cache.guild.myGuildInfo.guildId));
            MsgManager.addBroadCast("任命成员成功");
            
        }

        private function onGuildQuitHandler(event:DataEvent) : void
        {
            var onClickHandler:Function;
            var dataEvent:* = event;
            onClickHandler = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.guildProxy.memberOper(0, cache.role.playerInfo.playerId, EGuildPosition.EGuildNotMember);
                    Alert.resetToDefault();
                }
                
            }
            ;
            var htmlContent:String;
            Alert.show(htmlContent, null, Alert.OK | Alert.CANCEL, null, onClickHandler);
            
        }

        private function onGuildQuitSuccessHandler(event:DataEvent) : void
        {
            if (this._guildModule && this._guildModule.parent)
            {
                this._guildModule.parent.removeChild(this._guildModule);
            }
            MsgManager.addBroadCast("您已成功退出了仙盟");
            
        }

        private function onGuildDisbandHandler(event:DataEvent) : void
        {
            var htmlContent:String;
            var dataEvent:* = event;
            var myGuildInfo:* = cache.guild.myGuildInfo;
            if (myGuildInfo)
            {
                if (myGuildInfo.position == EGuildPosition._EGuildLeader)
                {
                    var onClickHandler:* = function (param1:int) : void
            {
                if (param1 == Alert.OK)
                {
                    GameProxy.guildProxy.disbandGuild();
                    Alert.resetToDefault();
                }
                
            }
            ;
                    htmlContent = "仙盟解散后，仙盟仓库中的物品将会清除。\n您确定要解散您的仙盟" + myGuildInfo.guildName + "吗？";
                    Alert.show(htmlContent, null, Alert.OK | Alert.CANCEL, null, onClickHandler);
                }
                else
                {
                    MsgManager.addBroadCast("您没有权限解散仙盟");
                }
            }
            
        }

        private function onGuildDisbandSuccessHandler(event:DataEvent) : void
        {
            if (this._guildModule && this._guildModule.parent)
            {
                this._guildModule.parent.removeChild(this._guildModule);
            }
            MsgManager.addBroadCast("您已成功解散了仙盟");
            
        }

        private function onGuildApplyPlayersGuildHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as int;
            GameProxy.guildProxy.applyPlayersGuild(_loc_2);
            
        }

        private function onGuildApplyPlayersGuildSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("发送申请成功");
            
        }

        private function onGuildPushInviteInfoHandler(param1:Object) : void
        {
            if (this._guildListModule)
            {
                HighlightManager.instance.glowEffectButton(this._guildListModule.inviteBtn, true);
            }
            MsgManager.addBroadCast("您有新的仙盟邀请信息！");
            
        }

        private function onGuildNewApplyHandler(param1:Object) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.HighlightGameUI, {type:"Navbar", name:ModuleType.Guild}));
            cache.guild.hasNewApply = true;
            
        }

        private function onGuildWelcomeHandler(param1:Object) : void
        {
            if (this._welcomeIcon == null)
            {
                this._welcomeIcon = new WelcomeHintIcon();
            }
            UiHintIconView.instance.addHintIcon(this._welcomeIcon);
            
        }

        private function onGuildNewMemberHandler(param1:SPublicMiniPlayer) : void
        {
            if (param1)
            {
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.OpenWelcomeNewMemberWindow, param1));
            }
            
        }

        private function onGuildUpdateHandler(event:DataEvent) : void
        {
            GameProxy.guildProxy.updateGuild();
            
        }

        private function onGuildUpdateSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("升级仙盟成功！");
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetInfo, 0));
            
        }

        private function onGuildDonateMoneyHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["option"] as EOperOption;
            var _loc_3:* = event.data["num"] as int;
            GameProxy.guildProxy.donateMoney(_loc_2, _loc_3);
            
        }

        private function onGuildDonateMoneySuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("捐献成功！");
            
        }

        private function onGuildSendMailHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["title"] as String;
            var _loc_3:* = event.data["content"] as String;
            GameProxy.guildProxy.guildMail(_loc_2, _loc_3);
            
        }

        private function onGuildSendMailSuccessHandler(event:DataEvent) : void
        {
            this._massSendWindow.clear();
            MsgManager.addBroadCast("发送成功！");
            
        }

        private function onGuildSendChatHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data as String;
            GameProxy.chatProxy.SendMessage(EChatType._EChatTypeGuildPrivate, _loc_2);
            
        }

        private function onGuildSendChatSuccessHandler(event:DataEvent) : void
        {
            this._massSendWindow.clear();
            MsgManager.addBroadCast("发送成功！");
            
        }

        private function onGuildSendWelcomeHandler(event:DataEvent) : void
        {
            var _loc_2:* = event.data["option"] as EOperOption;
            var _loc_3:* = event.data["toPlayerName"] as String;
            GameProxy.guildProxy.guildWelcome(_loc_2, _loc_3);
            
        }

        private function onGuildSendWelcomeSuccessHandler(event:DataEvent) : void
        {
            MsgManager.addBroadCast("欢迎发送成功！");
            this._welcomeNewWindow.hide();
            
        }

        public function get guildModule() : GuildModule
        {
            return this._guildModule;
        }

    }
}
